from base_restful.const import BaseInfo
from base_restful.crm import *
from base_restful.finance import *

BaseInfo.active = "backup"


def bill_test():
    # 切换至app登录
    BaseInfo.login.change_app()
    # 拿到登录修理厂名称
    org_name = BaseInfo.login.get_user()['orgName']
    print("修理厂名称", org_name)
    # 切换回pc平台登录
    BaseInfo.login.change_pc()
    bill = finance_create_receipt_bill({"garageName": org_name})
    bill_id = bill['data']
    print(bill)
    print(finance_send_receipt_bill(bill_id))
    print(finance_client_check_bill(bill_id))
    print(finance_bill_audit(bill_id, 6))

    bill_info = finance_receipt_bill_detail(bill_id)['data']

    billTotalPrice = bill_info['billTotalPrice']

    print(finance_offline_order_bill_gather(bill_id, billTotalPrice))


def send_mail(bill_id, email):
    BaseInfo.login.change_pc()
    print("发送账单到邮箱")
    print("bill_id", bill_id, "email", email)
    print(finance_receipt_bill_send_mail(bill_id, email))


def send_mail_invoice(invoice_id, email):
    BaseInfo.login.change_pc()
    print("发送发票到邮箱")
    print("invoice_id", invoice_id, "email", email)
    print(finance_receipt_invoice_send_mail(invoice_id, email))
